<?php

include_once 'albummodel.php';

$page1 = new pager();
$list_random_img = get_random_image();
$list_image_new = get_image_new();
if (isset($_GET["catid"])) {    
    echo true;
//if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
    $targetFile = str_replace('//', '/', $targetPath) . $_FILES['Filedata']['name'];

    move_uploaded_file($tempFile, $targetFile);
    $date = date("Y-m-d H:i:s",  time());
    $array = array(
        "id" => "''",
        "user_id" => "{$_POST["userid"]}",        
        "image_name" => "'{$_FILES["Filedata"]["name"]}'",
        "date_upload" => "'{$date}'",
        "status" => "1"
    );
    them_moi_album($array);

//}
}
 if($_GET["action"] == "delete_image"){
        $name = get_name_image_by_id($_GET["id"]);
        @unlink("data/album/{$name}");
        echo xoa_album($_GET["id"]);
    }
?>
